<template>
  <el-table
    :data="tableData"
    style="width: 100%"
    :row-class-name="tableRowClassName">
    <el-table-column 
      prop="date"
      label="学号"
      width="200">
    </el-table-column>
    <el-table-column
      prop="name"
      label="姓名"
      width="200">
    </el-table-column>
    <el-table-column 
      prop="score"
      label="绩点">
    </el-table-column>
  </el-table>
  
</template>

<style>
  .el-table .warning-row {
    background: rgb(240, 36, 9);
  }

  .el-table .success-row {
    background: #f0f9eb;
  }
</style>

<script>
  export default {
    methods: {
      tableRowClassName({row, rowIndex}) {
        if (rowIndex === 2) {
          return 'warning-row';
        } else if (rowIndex === 1) {
          return 'success-row';
        }
        return '';
      }
    },
    data() {
      return {
        tableData: [{
          date: '2001011',
          name: '张三',
          score: '2.7',
        }, {
          date: '2001023',
          name: '李四',
         score: '3.5'
        }, {
          date: '2001021',
          name: '王五',
          score: '2.1',
        }, {
          date: '2001044',
          name: '晓广',
          score: '3.0'
        },{
          date: '2001053',
          name: '胜龙',
          score: '2.8'
        }
        ]
      }
    }
  }
</script>